<?php


namespace Admin\Controller;


/**
 * 后台首页控制器
 * 主要获取首页聚合数据
 */
class BoothmakeController extends AdminController {
    //展位首页。。目前没有
    public function booth_index(){
        $where=array();
        $data = $this->lists('Changjing',$where,'id asc');
		$this->assign('manyou',$data);
	    $this->display();
	}

	//展位装修
	public function booth_zhuangxiu(){
	    $this->display();
	}

	//漫游管理
	public function manyou_guanli(){
		$where=array();
        $data = $this->lists('Changjing',$where,'id asc');
		$this->assign('manyou',$data);
	    $this->display();
	}

	//资料管理
	public function ziliao_guanli(){
	    $this->display();
	}

	//形象管理
	public function xingxiang_guanli(){
	    $this->display();
	
	}
	//导航管理
	public function nav_guanli(){
	    $this->display();
	
	}

	//功能管理
	public function function_guanli(){
	     $this->display();
	
	}

	//数据管理
	public function data_guanli(){
	     $this->display();
	}



	//删除操作
	public function del(){
		$id=array_unique((array)I('uid',0));
		if(empty($id)){
			$this->error('请输入数据!');

		}
		$where=array('uid'=>array('in',$id));
		if(M('Customer_info')->where($where)->delete()){
			S('DB_CONFIG_DATA',null);
			//记录行为
			action_log('update_config','Customer_info',$id,UID);
			$this->success('删除成功');
		}else{
			$this->error('删除失败');
		}
	}

	//场景添加
	public function edit($id=0){
		if(IS_POST){
			$data=I('post.');
			$data[id]=$id;
			//$changjing=D('Changjing');
			//2016/12/27$data=$changjing->create();
			//var_dump($id);exit;
		$upload=new Upload();
		//$upload->maxSize=5000;//图片大小
		$uplado->exts=array('jpg','gif','png');//设置图片上传类型
		$upload->rootPath='./front/';//摄像图片上传根目录
		//$upload->saveName=array('date','Y-m-d');
		$upload->savePath="image/cube/$id/";//设置图片上传目录
		//上传图片
		$info=$upload->upload();
		
		//var_dump($info);
		//die();


		 if(!$info){
			$function=M('Changjing');
			$function->where('id='."$id")->delete();
			
			$this->error($upload->getError());
			
		 }else{
           $form=M('Changjing');
		   $data['head_picture_path']=$info['f']['savename'];
		  
           $form->where('id='."$id")->save($data);

		   $data['right_picture_path']=$info['r']['savename'];
		
           $form->where('id='."$id")->save($data);

		  $data['back_picture_path']=$info['b']['savename'];
          $form->where('id='."$id")->save($data);

		  $data['left_picture_path']=$info['l']['savename'];
          $form->where('id='."$id")->save($data);

		  $data['up_picture_path']=$info['u']['savename'];
          $form->where('id='."$id")->save($data);

		  $data['down_picture_path']=$info['d']['savename'];
          $form->where('id='."$id")->save($data);
		 
	        
			
			
			 $this->success('更新成功！');
		         
           }

		
		}else{
			$info=array();
			$info=M('Changjing')->find($id);
			$this->assign('info',$info);$this->display();
		}
            
		
		
       

		
	}
	public function add(){
     if(IS_POST){
		$data=I('post.');
		$name=I('name');
		if($_POST['name']!==""&&$_POST['address']!==""){
		
		
		
		$Changjing=M('Changjing');
        $add=$Changjing->add($data);  //此处$add就代表id，我暂时也不知道为什么，稍后研究
		//$id=$Changjing->where('name'.'='.$data[name])->getField('id');//如果用此处的id，输入场景名称为中文就会出现错误，有待研究
		//var_dump($add);exit;

		$upload=new Upload();
		//$upload->maxSize=5000;//图片大小
		$uplado->exts=array('jpg','gif','png');//设置图片上传类型
		$upload->rootPath='./front/';//摄像图片上传根目录
		//$upload->saveName=array('date','Y-m-d');
		$upload->savePath="image/cube/$add/";//设置图片上传目录
		//上传图片
		$info=$upload->upload();
		
		//var_dump($info);
		//die();


		if(!$info){
			$function=M('Changjing');
			$function->where('id='."$add")->delete();
			
			$this->error($upload->getError());
			
		}else{
          $form=M('Changjing');
		  $data['head_picture_path']=$info['f']['savename'];
		  //$data['head_picture_path']='front'.'/'.'image'.'/'.'cube'.'/'."$add".'/'.$info['f']['savename'];
          $form->where('id='."$add")->save($data);

		  $data['right_picture_path']=$info['r']['savename'];
		  //$data['right_picture_path']='front'.'/'.'image'.'/'.'cube'.'/'."$add".'/'.$info['r']['savename'];
          $form->where('id='."$add")->save($data);

		  $data['back_picture_path']=$info['b']['savename'];
		  //$data['back_picture_path']='front'.'/'.'image'.'/'.'cube'.'/'."$add".'/'.$info['b']['savename'];
          $form->where('id='."$add")->save($data);

		  $data['left_picture_path']=$info['l']['savename'];
		  //$data['left_picture_path']='front'.'/'.'image'.'/'.'cube'.'/'."$add".'/'.$info['l']['savename'];
          $form->where('id='."$add")->save($data);

		  $data['up_picture_path']=$info['u']['savename'];
		  //$data['up_picture_path']='front'.'/'.'image'.'/'.'cube'.'/'."$add".'/'.$info['u']['savename'];
          $form->where('id='."$add")->save($data);

		  $data['down_picture_path']=$info['d']['savename'];
		  //$data['down_picture_path']='front'.'/'.'image'.'/'.'cube'.'/'."$add".'/'.$info['d']['savename'];
          $form->where('id='."$add")->save($data);
		 
	        
			
			
			 $this->success('上传成功！');
		         
           }
		}else{
		  $this->error("请输入场景名称和场景地址");
		}
	   }else{
	     $this->display('changjing_add');
	   }
	 }


	 //展位首页展位预览
	 public function quanjing($id=0){
		$data=$_GET['id'];
		
	    $this->display();
	}
	

}




?>